<template>
    <view>
		<view class="cu-list menu sm-border card-menu margin-top guoshao-menu" >
			<view class="cu-item guoshao-menu">
				<view class="">
					<view class="guoshao-touxiang-one">
						<image src="../../static/images/user.png" v-if="!isLogin"></image>
						<image :src="user.avatarUrl" v-if="isLogin"></image>
					</view>
					<view class="guoshao-user-name">
						<text class="text-grey" v-if="!isLogin">用户名</text>
						<text class="text-black" v-if="isLogin">{{user.nickName}}</text>
					</view>
				</view>
				<view class="action">
					<button open-type="getUserInfo" class="cu-btn round lines-blue" @click="miniLogin" v-if="!isLogin">
						登录
					</button>
				</view>
			</view>
		</view>
		<view class="cu-list menu sm-border card-menu margin-top" >
			
			<!-- <view class="cu-item arrow" @click="handlerRecord">
				<view class="content">
					<text class="cuIcon-record text-blue"></text>
					<text class="text-black">解析记录</text>
				</view>
			</view> -->
			<view class="cu-item arrow" @click="handlerContactAuthor">
				<view class="content">
					<text class="cuIcon-people text-blue"></text>
					<text class="text-black">联系作者</text>
				</view>
			</view>
			
			<view class="cu-item arrow" >
				<button class="cu-btn content" open-type="share">
					<text class="cuIcon-share text-blue"></text>
					<text class="text-black">分享给朋友</text>
				</button>
			</view>
			<view class="cu-item arrow" @click="handlerClearCache">
				<view class="content">
					<text class="cuIcon-delete text-blue"></text>
					<text class="text-black">清除缓存</text>
				</view>
			</view>
		
			<view class="cu-item arrow" v-if="admin" @click="jumpClick" 
			data-link="/pages/talent/approve/approve">
				<view class="content">
					<text class="cuIcon-edit text-blue"></text>
					<text class="text-black">创作者审核</text>
				</view>
			</view>
			
		</view>

    </view>
</template>

<script>
/*
 * Author: 郭少
 * github: https://github.com/guoshao99/wallpaper-applet
 * gitee: https://gitee.com/guoshao99/wallpaper-applet
 * QQ：2549789059
 * 微信：2549789059
 */

const constants = require('../../utils/constants.js');
const http = require('../../utils/http.js');

export default {
    components: {
    },
    data() {
        return {
			user: uni.getStorageSync(constants.APP_USER_INFO),
			isLogin: uni.getStorageSync(constants.IS_SUCCESS_KEY),
        };
    },
    onLoad() {
        let that = this; //配置信息  begin
    },
    onShow: function (options) {
        let that = this;
		that.setData({
		    user: uni.getStorageSync(constants.APP_USER_INFO),
			isLogin:uni.getStorageSync(constants.IS_SUCCESS_KEY),
		});
        
    },
    onHide() {
		
    },

	onShareAppMessage(res) {
		let that = this;
		return {
			title: '抖音、快手短视频一键去水印，去水印就是这样简单',
			path: '/pages/index/index',
			//imageUrl:'../../static/images/yaoqing.jpg'
		}
	},
	onShareTimeline: function () {
		let that = this;
	    return {
	        title: '抖音、快手短视频一键去水印，去水印就是这样简单',
			path: '/pages/index/index',
			//imageUrl:'../../static/images/yaoqing.jpg'
	    }
	},
    methods: {
		handlerRecord:function(){
			
		},
		handlerContactAuthor:function(){
			uni.setClipboardData({
			    data: '微信 2549789059',
			    success: function (res) {
			      uni.showModal({
			      	title:'提示',
					content:'已复制联系方式:微信 2549789059'
			      })
			    }
			});
		},
		handlerClearCache: function (e) {
		    uni.showModal({
		        title: '提示',
		        content: '确定清除缓存吗？',
		        success(res) {
		            if (res.confirm) {
		                //Authentication.clearCache();
		                uni.showToast({
		                    title: '清除成功'
		                });
		                // uni.reLaunch({
		                //     url: '/pages/index/index'
		                // });
		            }
		        }
		    });
		},
        jumpClick: function (e) {
			
			let that= this;
			
            let tp = e.currentTarget.dataset.tp;
			let link = e.currentTarget.dataset.link;
			
			uni.navigateTo({
				url: link,
				 fail (error) {
				    }
			});
        },
		miniLogin:function(){
			let that = this;
			uni.getUserProfile({
				desc:'用于小程序内展示',
				success: function(res) {
					uni.setStorageSync(constants.APP_USER_INFO,res.userInfo);
					uni.setStorageSync(constants.IS_SUCCESS_KEY,true);
					console.log(res);
					that.isLogin = true;
					that.user = res.userInfo;
				},
				fail: function (err) {
					console.log(err);
				},
				complete:function(){
				}
			})
		}
		

    }
};
</script>
<style>
@import './ucenter.css';
</style>
